home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #4 / Amiga Plus CD - 2000 - No. 4.iso / Tools / Commo-Support / Disk-Archive / includes-1_4.dms / includes-1_4.adf / i.zoo / exec / macros.i < prev    next >
Encoding:
Text File  |  1989-12-18  |  2.4 KB  |  143 lines

  1.     IFND    EXEC_MACROS_I
  2. EXEC_MACROS_I     SET     1
  3. **
  4. **    $Filename: exec/macros.i $
  5. **    $Release: 1.4 $
  6. **    $Revision: 36.2 $
  7. **    $Date: 89/12/17 23:56:00 $
  8. **
  9. **    Handy macros for assembly language programmers.
  10. **
  11. **    (C) Copyright 1985,1986,1987,1988,1989 Commodore-Amiga, Inc.
  12. **        All Rights Reserved
  13. **
  14.  
  15. ;How detailed debugging information should be.  Zero is no debugging.
  16.         IFND    DEBUG_DETAIL
  17. DEBUG_DETAIL      SET    0
  18.         ENDC
  19.  
  20. JSRLIB        MACRO
  21.         XREF    _LVO\1
  22.         jsr    _LVO\1(a6)
  23.         ENDM
  24.  
  25. JMPLIB        MACRO
  26.         XREF    _LVO\1
  27.         jmp    _LVO\1(a6)
  28.         ENDM
  29.  
  30. BSRSELF     MACRO
  31.         XREF \1
  32.         bsr  \1
  33.         ENDM
  34.  
  35. BRASELF     MACRO
  36.         XREF \1
  37.         jsr  \1
  38.         ENDM
  39.  
  40. BLINK        MACRO
  41.         IFNE    DEBUG_DETAIL
  42.           bchg.b #1,$bfe001  ;Toggle the power LED
  43.         ENDC
  44.         ENDM
  45.  
  46. CLEAR        MACRO
  47.         moveq.l #0,\1
  48.         ENDM
  49.  
  50. CLEARA        MACRO
  51.         suba.l    \1,\1    ;Quick way to put zero in an address register
  52.         ENDM
  53.  
  54. *************************************************************************
  55.         IFND    PRINTF
  56. PRINTF        MACRO    ; level,<string>,...
  57.         IFGE    DEBUG_DETAIL-\1
  58.         XREF    kprint_macro
  59. PUSHCOUNT    SET    0
  60.  
  61.         IFNC    '\9',''
  62.         move.l    \9,-(sp)
  63. PUSHCOUNT    SET    PUSHCOUNT+4
  64.         ENDC
  65.  
  66.         IFNC    '\8',''
  67.         move.l    \8,-(sp)
  68. PUSHCOUNT    SET    PUSHCOUNT+4
  69.         ENDC
  70.  
  71.         IFNC    '\7',''
  72.         move.l    \7,-(sp)
  73. PUSHCOUNT    SET    PUSHCOUNT+4
  74.         ENDC
  75.  
  76.         IFNC    '\6',''
  77.         move.l    \6,-(sp)
  78. PUSHCOUNT    SET    PUSHCOUNT+4
  79.         ENDC
  80.  
  81.         IFNC    '\5',''
  82.         move.l    \5,-(sp)
  83. PUSHCOUNT    SET    PUSHCOUNT+4
  84.         ENDC
  85.  
  86.         IFNC    '\4',''
  87.         move.l    \4,-(sp)
  88. PUSHCOUNT    SET    PUSHCOUNT+4
  89.         ENDC
  90.  
  91.         IFNC    '\3',''
  92.         move.l    \3,-(sp)
  93. PUSHCOUNT    SET    PUSHCOUNT+4
  94.         ENDC
  95.  
  96.         movem.l a0/a1,-(sp)
  97.         lea.l    PSS\@(pc),A0
  98.         lea.l    4*2(SP),A1
  99.         BSR     kprint_macro
  100.         movem.l (sp)+,a0/a1
  101.         bra.s    PSE\@
  102.  
  103. PSS\@        dc.b    \2
  104.         IFEQ    (\1&1)  ;If even, add CR/LF par...
  105.            dc.b 10,13
  106.         ENDC
  107.         dc.b    0
  108.         ds.w    0
  109. PSE\@
  110.         adda.l    #PUSHCOUNT,sp
  111.         ENDC    ;IFGE    DEBUG_DETAIL-\1
  112.         ENDM    ;PRINTF    MACRO
  113.         ENDC    ;IFND    PRINTF
  114.  
  115.  
  116. ;----------------------------------------------------------------------------
  117. ;Push a set of registers onto the stack - undo with POPM.
  118. ;These macros do not nest.
  119. ;        PUSHM   d2/a2/a5
  120. ;        ...code...
  121. ;        POPM
  122. ;        RTS
  123. ;
  124. PUSHM_COUNT            SET    0
  125. PUSHM                MACRO
  126.                 IFGT    NARG-1
  127.                 FAIL    !!!! TOO MANY ARGUMENTS TO PUSHM !!!!
  128.                 ENDC
  129. PUSHM_COUNT            SET    PUSHM_COUNT+1
  130. PUSHM_\*VALOF(PUSHM_COUNT)      REG     \1
  131.                 movem.l PUSHM_\*VALOF(PUSHM_COUNT),-(sp)
  132.                 ENDM
  133. ;
  134. ;Undo most recent PUSHM
  135. ;
  136. POPM                MACRO
  137.                 movem.l (sp)+,PUSHM_\*VALOF(PUSHM_COUNT)
  138.                 ENDM
  139. ;----------------------------------------------------------------------------
  140.  
  141.  
  142.     ENDC    ; EXEC_MACROS_I
  143.